package com.zzl.example.springboottest.util;

import com.zzl.example.springboottest.bean.SourceBean;
import com.zzl.example.springboottest.bean.TargetBean;
import org.springframework.beans.BeanUtils;

/**
 * @ClassName convertUtil
 * @Description JavaBean之间的转换
 * @Author Zengliang Zheng
 * @Date 2023/7/21 16:56
 * @Version 1.0
 */
public class ConvertUtil {
    public static void main(String[] args) {
        convert();
    }

    public static void convert(){
        // 需要将SourceBean转换为TargetBean
        SourceBean sourceBean = new SourceBean();
        sourceBean.setName("张三");
        sourceBean.setAge(18);

        TargetBean targetBean = new TargetBean();
        BeanUtils.copyProperties(sourceBean, targetBean);
        System.out.println(targetBean);
    }
}

    
